﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;
using Microsoft.Xna.Framework.Input;

namespace DS.SludgeEngine.Base.GlobalContent
{
    [Serializable]
    [XmlRoot()]
    public class InputConfiguration
    {
        [XmlArray("InputItems")]
        [XmlArrayItem("InputItem")]
        public List<InputItem> Items
        {
            get;
            set;
        }

        public static InputConfiguration Deserialise(string xml)
        {
            XmlSerializer serialiser = new XmlSerializer(typeof(InputConfiguration));
            MemoryStream stream = new MemoryStream();
            stream.Write(Encoding.ASCII.GetBytes(xml), 0, xml.Length);
            stream.Position = 0;
            return serialiser.Deserialize(stream) as InputConfiguration;
        }
    }

    public class InputItem
    {
        [XmlAttribute()]
        public Actions Action
        {
            get;
            set;
        }

        [XmlAttribute()]
        public Keys Key
        {
            get;
            set;
        }

    }
}
